package com.baturu.vin.dffx.dal.dao;

import com.baturu.vin.dffx.dto.DffxCarSystemDTO;
import com.baturu.vin.dffx.dto.DffxVinDTO;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Options;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * @Author: chenjiahao
 * @Time: 2018/9/25
 */
public interface DffxCarSystemDAO {
    @Select({"SELECT btrId ",
            "FROM dffx_cartype_btrid ",
            "WHERE carSystem = #{dto.carSystem}",
            "AND displacement = #{dto.displacement}",
            "AND transmission = #{dto.transmissionType}",
            "AND year = #{dto.mj}"})
    List<DffxCarSystemDTO> queryBtrIdByCondition(@Param("dto") DffxVinDTO dto );

    @Insert({"INSERT INTO dffx_cartype_btrid (",
            "btrId,",
            "carSystem,",
            "displacement,",
            "transmission,",
            "year",
            ") values (",
            "#{dto.btrId},",
            "#{dto.carSystem},",
            "#{dto.displacement},",
            "#{dto.transmission},",
            "#{dto.year})"})
    @Options(useGeneratedKeys = true, keyProperty = "dto.btrId")
    int insertCarSystemBtrId(@Param("dto") DffxCarSystemDTO dffxCarSystemBtrIdDTO);

    @Select({"SELECT carSystemId ",
            "FROM dffx_carsystem",
            "WHERE carSystem = #{carSystem}"})
    DffxCarSystemDTO queryCarSystemIdBycarSystem(@Param("carSystem") String carSystem);
}
